package kr.co.mustgo.model.dao.freeboard;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import kr.co.mustgo.domain.freeboard.FreeComment;
import kr.co.mustgo.util.BoardUtilities;

@Repository
public class CommentDAOImpl implements CommentDAO{

	@Autowired
	private SqlSessionTemplate session;
	
	@Override
	public int insertComment(FreeComment comment) {
		return session.insert(makeSqlId("insertComment"), comment);
	}

	@Override
	public List<FreeComment> selectCommentList(int code) {
		return session.selectList(makeSqlId("selectCommentList"), code);
	}


	@Override
	public int deleteComment(int reCode) {
		return session.delete(makeSqlId("deleteContentByReCode"), reCode);
	}
	
	@Override
	public int deleteCommentCode(int code) {
		return session.delete(makeSqlId("deleteContentByCode"), code);
	}

	
	private String makeSqlId(String reCode) {
		return "comment." + reCode;
	}



}
